package com.mjfeed.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;

import org.apache.commons.lang3.builder.CompareToBuilder;

/**
 * @description Entity 排序基类
 * @author zhaominglei
 * @date 2014年9月21日
 */
@MappedSuperclass
public abstract class OrderEntity extends BaseEntity implements Serializable,Comparable<OrderEntity> {
	private static final long serialVersionUID = 1972283888091229346L;

	/** 排序 */
	private Integer orders;

	@Column(name="orders")
	public Integer getOrders() {
		return orders;
	}

	public void setOrders(Integer orders) {
		this.orders = orders;
	}
	
	/**
	 * 实现compareTo方法
	 * 
	 * @param orderEntity
	 *            排序对象
	 * @return 比较结果
	 */
	@Override
	public int compareTo(OrderEntity orderEntity) {
		return new CompareToBuilder().append(getOrders(), orderEntity.getOrders()).append(getId(), orderEntity.getId()).toComparison();
	}
}
